package br.jus.tjpe.bean;

import java.security.Principal;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

public class LoginBean {
	
	private String username;
	private String password;
	
	public String login() {
		
		return "principal";
	}
	
	public Principal getUser() {
		return FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
	}

	public String logout() {
		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
		((HttpSession) externalContext.getSession(false)).invalidate();
        return "principal";
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

}
